//
// @Auther: by wujehy 
// @Email:wujehy@qq.com
// @Data:20-2-14
// @Time:下午7:00
//

#ifndef E2EEMESSAGE_E2EEFACTORY_H
#define E2EEMESSAGE_E2EEFACTORY_H

#include <signal_protocol_types.h>
#include "CommonType.h"
#include "OPKManager.h"

using namespace GeeJoan::E2EE;
namespace GeeJoan
{
    namespace E2EE
    {
        namespace SDK
        {
            class E2EEFactory : public Common::E2EEBase {
            private:
                pthread_mutex_t global_mutex;
                pthread_mutexattr_t global_mutex_attr;
                //基础idk
                ec_key_pair *m_idk = nullptr;
                // 基础 spk
                ec_key_pair *m_spk = nullptr;

                signal_context *m_global_context = nullptr; // 全局变量

                std::unique_ptr<OPKManager> e2EeopkManager; // opk 管理器

                signal_protocol_store_context *m_store_context = 0; //全局存储容器

                uint32_t m_local_registration_id = 0;

            public:
                E2EEFactory();

                virtual ~E2EEFactory();

                void setMIdk(const KeyPairDataType &mIdk);

                void setMSpk(const KeyPairDataType &mSpk);

                int creatIDK();

                int creatSPK();

                const std::unique_ptr<OPKManager> &getOpkManager() const;

                KeyPairDataType getMIdk() override;

                KeyPairDataType getMSpk() override;

                KeyPairDataType getMOpk() override;
            };
        };
    }
}


#endif //E2EEMESSAGE_E2EEFACTORY_H
